
interface PositionItem{
    lat:number|string;
    lon:number|string;
}
interface AddressItem{
    address:string;
    area:string;
    lat:number;
    lon:number;
    province:string;
}

interface CarOwenerInfo{
    carCode:string;
    carId:string;
    name:string;
    phone:string;
}

interface carRecommendItem{
    
    carCode:string
    carId:string
    carImg:string
    carLength:string
    carType:string
    dist:string
    lat:number
    licensePlateColor:string
    lon:number
    name:string
    phone:string
    positionDateTime:string
    ratifyLoad:string;
    // 下面两个属性列表接口中未返回
    address?:string;
    
}
interface carRecommendList{
    data:carRecommendItem[];
    total:number
}

interface ICarRecommendService {
    /**
     * 具体地址转经纬度
     * @param address 
     */
    getPositionFromAddress(address:string): ng.IHttpPromise<PositionItem>;
    /**
     * 从经纬度获取具体信息
     * @param latitude 
     * @param longitude 
     */
    getAddressFromPosition(latitude:number,longitude:number): ng.IHttpPromise<AddressItem>
    /**
     * 调车推荐列表
     * @param lon 
     * @param lat 
     * @param startCityCode 
     * @param endCityCode 
     */
    getCarRecommendList(lon:string,lat:string,startCityCode:string,endCityCode:string): ng.IHttpPromise<carRecommendList>
    /**
     * 获取调车推荐车主信息
     * @param carId 
     */
    getCarOwenerInfo(carId:string): ng.IHttpPromise<CarOwenerInfo>
}

class carRecommendService implements ICarRecommendService {
    constructor(private http: ng.IHttpService, private route: routeService) {
    }
    /**
     * 具体地址转经纬度
     * @param address 
     */
    getPositionFromAddress(address:string): ng.IHttpPromise<PositionItem>{
        return this.http<any>({
            method:"GET",
            url:this.route.getUrl("carowner/addresstoposition?address={{address}}",{
                address:address
            })

        })
    }
    /**
     * 从经纬度获取具体信息
     * @param latitude 
     * @param longitude 
     */
    getAddressFromPosition(latitude:number,longitude:number): ng.IHttpPromise<AddressItem>{
        return this.http<any>({
            method:"GET",
            url:this.route.getUrl("carowner/positiontoaddress?latitude={{latitude}}&longitude={{longitude}}",{
                latitude:latitude,
                longitude:longitude,
            })

        })
    }

    /**
     * 调车推荐列表
     * @param lon 
     * @param lat 
     * @param startCityCode 
     * @param endCityCode 
     */
    getCarRecommendList(lon:string,lat:string,startCityCode:string,endCityCode:string): ng.IHttpPromise<carRecommendList>{
        return this.http<any>({
            method:"GET",
            url:this.route.getUrl("carowner/findcar?lon={{lon}}&lat={{lat}}&startCity={{startCityCode}}&endCity={{endCityCode}}",{
                lon:lon,
                lat:lat,
                startCityCode:startCityCode,
                endCityCode:endCityCode
            })
        })
    }
    /**
     * 获取调车推荐车主信息
     * @param carId 
     */
    getCarOwenerInfo(carId:string): ng.IHttpPromise<CarOwenerInfo>{
        return this.http<any>({
            method:"GET",
            url:this.route.getUrl("carowner/getcarowner?carId={{carId}}",{
                carId:carId
            })

        })
    }

    


   

   

}

angular.module('carRecommendService',[]).service("carRecommendService",['$http','routeService',carRecommendService]);
